package com.ruoyi.produce.report.procedureTransfer.service;

import com.ruoyi.produce.base.procedure.mapper.ProcedureMapper;
import com.ruoyi.produce.report.procedureTransfer.domain.ProcedureTransfer;
import com.ruoyi.produce.report.procedureTransfer.mapper.ProcedureTransferMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class ProcedureTransferServiceImpl implements IProcedureTransferService{

    @Autowired
    private ProcedureTransferMapper procedureTransferMapper;
    @Autowired
    private ProcedureMapper procedureMapper;

    /**
     * 查找工序移交明细报表
     * @param procedureTransfer
     * @return
     */
    @Override
    public List<ProcedureTransfer> selectProcedureTransferForm(ProcedureTransfer procedureTransfer) {
        List<ProcedureTransfer> procedureTransferList = procedureTransferMapper.selectProcedureTransferForm(procedureTransfer);
        for (ProcedureTransfer s : procedureTransferList) {
            // 当前工序
            s.setProcedureCurrentName(procedureMapper.selectProcedureById(s.getProcedureCurrentId()).getProcedureName());

            // 转到工序
            if (s.getProcedureTransferId().equals("0")) {
                // 完工
                s.setProcedureTransferName("完工");
            } else {
                s.setProcedureTransferName(procedureMapper.selectProcedureById(s.getProcedureTransferId()).getProcedureName());
            }
        }
        return procedureTransferList;
    }
}
